﻿using System;
using System.Linq;
using System.Text;
using BO.Infrastructure.Utils;
using BO.Video;
using GUI.Extensions;

namespace GUI.Controls.Video
{
    public partial class MenuLeft : System.Web.UI.UserControl
    {
        private const string LiFormat = "<li {5} rel=\"{3}\" pagingUrl='{4}'><a href=\"{0}\" title=\"{2}\">{1}</a></li>";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var videoZoneId = RequestExtensions.VideoZoneId;
                var sb = new StringBuilder();

                var videoZone = VideoBO.GetAllVideoZones();
                sb.AppendFormat(LiFormat, "/video.htm", "Tất cả", "Tất cả", 0, "/video/", videoZoneId == -1 ? "class=\"active\"" : string.Empty);
                if (videoZone != null && videoZone.Any())
                {
                    foreach (var zone in videoZone.Where(zone=>zone.ParentId ==0))
                    {
                        sb.AppendFormat(LiFormat,
                            zone.Url,
                            zone.Name,
                            PresentationUtils.EnCode(zone.Name),
                            zone.Id,
                            string.Format("/video/{0}/", zone.DisplayUrl),
                             videoZoneId == zone.Id ? "class=\"active\"" : string.Empty);
                    }
                    ltrData.Text = sb.ToString();
                    return;
                }
                Visible = false;
            }
        }


    }
}